package org.ihelpuoo.orm.handler.conn;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

import org.ihelpuoo.lang.ObjectUtils;
import org.ihelpuoo.orm.ObjectRule;
import org.ihelpuoo.orm.filter.FieldFilter;
import org.ihelpuoo.orm.handler.ObjectProcessor;
import org.ihelpuoo.orm.handler.FieldHandler;

public class ConnDelObjectFieldHandler extends FieldHandler
{

	public ConnDelObjectFieldHandler(ObjectProcessor beanHandler)
	{
		super(beanHandler);
	}

	@Override
	public void processWithoutExceptionHandle(ObjectRule br, Field f, Object src, Object obj, FieldFilter actived, FieldFilter locked, String prefix)
			throws Exception
	{
		Method getter = ObjectUtils.getGetter(obj.getClass(),f);
		Object v = (Object)getter.invoke(obj,(Object[])null);
		if (null == v)
			return;
		ObjectRule subRule = processor.getManual().getRule(v.getClass());
		processor.delete(subRule,src,v, null);
	}

}
